//
//  HEChatBar.h
//  HealthFamily
//
//  Created by 吴欧 on 2021/2/9.
//  Copyright © 2021 honglutec. All rights reserved.
//

#import <UIKit/UIKit.h>

NS_ASSUME_NONNULL_BEGIN


static CGFloat const kChatBarBottomOffset = 8.f;
static CGFloat const kChatBarTextViewBottomOffset = 6;
static CGFloat const kLCCKChatBarTextViewFrameMinHeight = 37.f; //kLCCKChatBarMinHeight - 2*kChatBarTextViewBottomOffset;
static CGFloat const kLCCKChatBarTextViewFrameMaxHeight = 102.f; //kLCCKChatBarMaxHeight - 2*kChatBarTextViewBottomOffset;
static CGFloat const kLCCKChatBarMaxHeight = kLCCKChatBarTextViewFrameMaxHeight + 2*kChatBarTextViewBottomOffset; //114.0f;
static CGFloat const kLCCKChatBarMinHeight = kLCCKChatBarTextViewFrameMinHeight + 2*kChatBarTextViewBottomOffset; //49.0f;

FOUNDATION_EXTERN NSString *const kLCCKBatchDeleteTextPrefix;
FOUNDATION_EXTERN NSString *const kLCCKBatchDeleteTextSuffix;

static CGFloat const LCCKAnimateDuration = .25f;

/**
 *  functionView 类型
 */
typedef NS_ENUM(NSUInteger, LCCKFunctionViewShowType){
    LCCKFunctionViewShowNothing /**< 不显示functionView */,
    LCCKFunctionViewShowFace /**< 显示表情View */,
    LCCKFunctionViewShowVoice /**< 显示录音view */,
    LCCKFunctionViewShowMore /**< 显示更多view */,
    LCCKFunctionViewShowKeyboard /**< 显示键盘 */,
};

@protocol HEChatBarDelegate;

/**
 *  信息输入框,支持语音,文字,表情,选择照片,拍照
 */
@interface HEChatBar : UIView

@property (nonatomic, weak) id<HEChatBarDelegate> delegate;

/**
 当前会话
 */
@property (nonatomic, weak) HEIMSession *session;

@property (nonatomic, readonly) UIViewController *controllerRef;

@property (nonatomic, strong) UserInfo *userInfo;

@property (nonatomic, assign) HEIMUserModelType type;

@property (nonatomic, strong) NSMutableArray <HEIMKitInfo *> *teamUserList; // @人时，弹出的群人员列表

/*!
 *
 缓存输入框文字，兼具内存缓存和本地数据库缓存的作用。同时也负责着输入框内容被清空时的监听，收缩键盘。内部重写了setter方法，self.cachedText 就相当于self.textView.text，使用最重要的场景：为了显示voiceButton，self.textView.text = nil;

 */
@property (copy, nonatomic) NSString *cachedText;

@property (copy, nonatomic) NSAttributedString *cachedAttrText;

@property (nonatomic, assign) LCCKFunctionViewShowType showType;

- (instancetype)initWithFrame:(CGRect)frame type:(HEIMUserModelType)type;

/*!
 * 在 `-presentViewController:animated:completion:` 的completion回调中调用该方法，屏蔽来自其它 ViewController 的键盘通知事件。
 */
- (void)close;

/*!
 * 对应于 `-close` 方法。
 */
- (void)open;

- (void)addATPerson:(HEIMKitInfo *)info isLong:(BOOL)isLong;


/*!
 * 追加后，输入框默认开启编辑模式
 */
- (void)appendString:(NSString *)string;
- (void)appendString:(NSString *)string beginInputing:(BOOL)beginInputing;
- (void)appendString:(NSString *)string mentionList:(NSArray<NSString *> *)mentionList;

/**
 *  结束输入状态
 */
- (void)endInputing;

/**
 *  进入输入状态
 */
- (void)beginInputing;

- (void)hidekeyBoard;


@end

/**
 *  LCCKChatBar代理事件,发送图片,地理位置,文字,语音信息等
 */
@protocol HEChatBarDelegate <NSObject>

/**
 发送消息
 */
- (void)sendMessage:(HEIMMessageModel *)message;

@optional

/*!
 *  chatBarFrame改变回调
 *
 *  @param chatBar
 */
- (void)chatBarFrameDidChange:(HEChatBar *)chatBar shouldScrollToBottom:(BOOL)shouldScrollToBottom;


/*!
 *  输入了 @ 的时候
 *
 */
- (void)didInputAtSign:(HEChatBar *)chatBar;

- (NSArray *)regulationForBatchDeleteText;

@end


NS_ASSUME_NONNULL_END
